
//当这个类被final修饰了，那么它就变成完全封闭状态了，所有办法都没法继承
final class Person {

}
//JDK17提供了新关键字sealed，该密封类可以开放给permits后面的类，sealed修饰的类一定有子类
sealed class Persons permits Man {

}
//如果子类不想被开放，那么它要用non-sealed修饰
non-sealed class Man extends Persons{

}

public class Test {


    public static void main4(String[] args) {
        var age=10;
        var name="hello";//var会自动推导出变量的类型


    }

    public static void main2(String[] args) {
        String data="one";
        int ret=0;
        switch(data){
            case "one":{
                ret=1;
                break;
            } case "two" :{
                ret=2;
                break;
            } default: {
                ret=-1;
                break;
            }
        }
        System.out.println(ret);
    }
    public static void main1(String[] args) {
        String data ="one";
        int ret=switch(data){
            case "one" -> 1;
            case "two" -> 2;
            default -> -1;
        };
        System.out.println(ret);
    }
    public static void main3(String[] args) {
        String data ="one";
        int ret=switch(data){
            case "one" : yield 1;
            case "two" : yield 2;
            default : yield -1;
        };
        System.out.println(ret);
    }
}
